package vivo;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int length = Integer.parseInt(in.nextLine());

        int[] area = new int[length];

        int planted = 0;
        for (int i = 0; i < length; i++) {
            area[i] = in.nextInt();
            if (1 == area[i]) {
                planted++;
            }
        }

        int plantedTree = 0;

        int flag = 0;
        for (int i = 0; i < length;) {
            if (area[i] == 1) {
                flag = i;
                i += 2;
            }
            if (i< length && area[i] != 1 && area[i + 1] != 1) {
                plantedTree++;
                i += 2;
            } else {
                i++;
            }

        }
        System.out.println(plantedTree);

        in.close();

    }
}